package com.kai.steering.data.service.entity.domainObject;

import cn.hutool.core.bean.BeanUtil;
import com.kai.steering.data.service.entity.po.UserQuestion;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ToString
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "UserQuestionDO对象", description = "用户与题目业务实体")

public class UserQuestionDO implements Serializable {
    private static final long serialVersionUID = 1L;
    @ApiModelProperty(value = "id")
    private String userQuestionId;
    @ApiModelProperty(value = "用户id")
    private String userId;
    @ApiModelProperty(value = "题目id")
    private String questionId;
    @ApiModelProperty(value = "收藏")
    private String collection;
    @ApiModelProperty(value = "做题次数")
    private Integer problemNumber;
    @ApiModelProperty(value = "错误次数")
    private Integer errorNumber;
    @ApiModelProperty(value = "笔记")
    private NoteDO noteDO;
    @ApiModelProperty(value = "存在0删除1")
    private Integer usable;
    @ApiModelProperty(value = "删除日期")
    private Date deleteDatetime;


    public UserQuestionDO(UserQuestion userQuestion) {
        convertUserQuestionDO(userQuestion);
    }
    public UserQuestionDO convertUserQuestionDO(UserQuestion userQuestion) {
        BeanUtil.copyProperties(userQuestion, this);

        return this;
    }
    public static List<UserQuestionDO> convertUserQuestionDOS(List<UserQuestion> userQuestions){
        return userQuestions.stream().map(userQuestion -> {
            return new UserQuestionDO(userQuestion);
        }).collect(Collectors.toList());
    }
}
